Shader "Dan/UI/UI_TargetCross"
{
    Properties
    {
     _Color ("Color", Color) = (0.07843138,0.3921569,0.7843137,1)
     _MainTex ("MainTex", 2D) = "white" {}
     _Speed ("Speed", Float ) = 4
     _Amplitude ("Amplitude", Range(0, 1)) = 0.1543558
     _Emission ("Emission", Float ) = 1
     [MaterialToggle] _UseBG ("UseBG", Float ) = 0
     _BG_Density ("BG_Density", Float ) = 32
     _BG_Opacity ("BG_Opacity", Range(0, 1)) = 0.75
     

    }
    
    SubShader
    {

        Tags { "IgnoreProjector"="True"
            "Queue"="Transparent"
            "RenderType"="Transparent" }
        LOD 100    
        Blend SrcAlpha OneMinusSrcAlpha
        ZWrite Off 
 
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            
            #include "UnityCG.cginc"
            #include "../ShaderLibs/UIFX.cginc"
            #include "../ShaderLibs/UVOperator.cginc"
            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };
            
            struct v2f
            {
                float4 vertex : SV_POSITION;    
                float2 uv : TEXCOORD0;
                
            };

             float4 _Color;
             sampler2D _MainTex; 
             float4 _MainTex_ST;
             float _Speed;
             float _Amplitude;
             float _Emission;
             float _BG_Density;
             fixed _UseBG;
             float _BG_Opacity;

            v2f vert ( appdata v )
            {
                
                v2f o;
                UNITY_INITIALIZE_OUTPUT(v2f ,o);
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;        
                return o;
            }
            
            fixed4 frag (v2f i ) : SV_Target
            {
                float2 uv = i.uv;
                uv = TRANSFORM_TEX(uv, _MainTex);
                float targetShape;
                TargetCross(_Speed,_Amplitude,uv,_MainTex,targetShape);
                clip(targetShape - 0.5);
                float3 finalColor =  _Color.rgb*_Emission;
                
                return fixed4(finalColor,targetShape);
                
            }
            ENDCG
        }
    }
    
    
    
}
